package com.self.cgqcompose.ui.components.areatype

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.self.cgqcompose.beans.Area9Bean
import com.self.cgqcompose.mock.MockJson
import com.self.cgqcompose.ui.components.areacode.AreaCode1
import com.self.cgqcompose.ui.components.areacode.AreaCode120
import com.self.cgqcompose.ui.components.areacode.AreaCode145
import com.self.cgqcompose.ui.components.areacode.AreaCode73
import com.self.cgqcompose.ui.components.areacode.AreaCode74
import com.self.cgqcompose.ui.components.areacode.AreaUnSupport

@Composable
fun AreaCode9(area9Bean: Area9Bean) {

    LazyColumn(verticalArrangement = Arrangement.spacedBy(10.dp)) {
        area9Bean.data.forEach { areaData ->
            item {
//                if (areaData.data.areaCode == 1) {
//                    AreaCode1(areaData)
//                }else  if (areaData.data.areaCode == 73) {
//                    AreaCode73(areaData)
//                }else  if (areaData.data.areaCode == 120) {
//                    AreaCode120(areaData)
//                } else {
//                    AreaUnSupport(areaData)
//                }
                when (areaData.data.areaCode) {
                    1 -> AreaCode1(areaData)
                    73 -> AreaCode73(areaData)
                    74 -> AreaCode74(areaData)
                    120 -> AreaCode120(areaData)
                    145 -> AreaCode145(areaData)
                    else -> AreaUnSupport(areaData)
                }
            }
        }
    }
}

@Preview
@Composable
fun AreaCode9Preview() {
    AreaCode9(MockJson.loadMockDataArea9(context = LocalContext.current))
}
